home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 14910 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.0 KB

  1. Path: news.cern.ch!danpop
  2. From: danpop@mail.cern.ch (Dan Pop)
  3. Newsgroups: cs.forum,cuhk.se.3420,comp.lang.c
  4. Subject: Re: Help: a very segmentation fault!
  5. Date: 15 Apr 96 23:37:55 GMT
  6. Organization: CERN European Lab for Particle Physics
  7. Message-ID: <danpop.829611475@news.cern.ch>
  8. References: <4ki7gu$bgc@eng_ser1.erg.cuhk.hk> <4kinqm$hnt@eng_ser1.erg.cuhk.hk> <4kiptc$ih5@eng_ser1.erg.cuhk.hk>
  9. NNTP-Posting-Host: ues5.cern.ch
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=US-ASCII
  12. Content-Transfer-Encoding: 7bit
  13. X-Newsreader: NN version 6.5.0 #7 (NOV)
  14.  
  15. In <4kiptc$ih5@eng_ser1.erg.cuhk.hk> wkso@se.cuhk.hk (--- Sam ---) writes:
  16.  
  17.  
  18. >: I've tried the program...  That's okay... except some syntax error...
  19. >
  20. >: One more thing...  What is your platform??  There's no "r+b" mode for
  21. >: fopen on unix systems...  
  22.  
  23. Please don't post such idiocies.  "r+b" is a valid mode on any platform
  24. supporting standard C, Unix included, as well as on most K&R C 
  25. implementations, which simply discarded the 'b' at the end of the string.
  26. "rb+" is problematic on pre-ANSI implementations, because it will be
  27. interpreted as "r" and not as "r+", because anything following the
  28. "spurious" 'b' will be discarded.  So, "rb+" and "r+b" are equivalent on
  29. ANSI C platforms but "r+b" works on pre-ANSI platforms, as well.
  30.  
  31. >: Default mode is binary for all files.
  32.  
  33. Nonsense.  In standard C (no matter the platform), the default is text.
  34. It just happen that there is no difference between text and binary on
  35. Unix, but this doesn't mean that the default is binary.
  36.  
  37. >    Yes ! You don't need to add "b" under UNIX ! It's easier
  38. >to do this assignment on UNIX platform !
  39.  
  40. Unix or not, the C language _requires_ the 'b' when dealing with binary
  41. streams.  You can't tell which will be the next platform you'll have to
  42. port your code to, and it's plain foolish to introduce an OS dependency
  43. simply by omitting the 'b' in fopen.  This omission buys you _nothing_.
  44.  
  45. Dan
  46. --
  47. Dan Pop
  48. CERN, CN Division
  49. Email: danpop@mail.cern.ch 
  50. Mail:  CERN - PPE, Bat. 31 R-004, CH-1211 Geneve 23, Switzerland
  51.